#!/bin/bash
#

for file in $(find /opt/data -type f); do
    bak_file=${file/data/test}

    if [ ! -f $bak_file ]; then
        echo "文件${file}备份丢失"
    else
        file_md5=$(md5sum $file | awk '{print $1}')
        bak_md5=$(md5sum $bak_file | awk '{print $1}')
        if [ $bak_md5 != $file_md5 ]; then
            echo "文件 ${file}备份数据不一致"
        else
            echo "文件备份已完成"
        fi
    fi
done
